package com.coda.app.mapper;

import com.coda.app.annotation.AutoFill;
import com.coda.appVo.history.HistoryItemVo;
import com.coda.entity.BrowsingHistory;
import com.coda.enumeration.OperationType;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;

@Mapper
public interface BrowsingHistoryMapper {
    /**
     * 分页查询历史浏览信息
     * @return
     */
    Page<HistoryItemVo> getHistory();

    /**
     * 根据房间id和用户id查询历史浏览记录
     * @param browsing
     * @return
     */
    @Select("select * from browsing_history where room_id = #{roomId} and user_id = #{userId}")
    BrowsingHistory getHistoryById(BrowsingHistory browsing);

    /**
     * 保存历史浏览记录
     * @param browsing
     */
    @AutoFill(OperationType.INSERT)
    void insert(BrowsingHistory browsing);

    /**
     * 跟新历史浏览记录
     * @param browsing
     */
    @AutoFill(OperationType.UPDATE)
    void update(BrowsingHistory browsing);
}
